﻿<%@ codepage=65001%>
<script language="JScript" runat="Server">
Array.prototype.get = function(i)
{
	return this[i];
}
function getjson(str)
{
	try
	{
		eval("var jsonStr = (" + str + ")");
	}
	catch(ex)
	{
		var jsonStr = null;
	}
	return jsonStr;
}
</script>
<!-- #include file="conn.asp" -->
<%
Session.CodePage=65001
Response.Charset="utf-8"
response.write request("userJson")
iType = request("userType")
userJson = request("userJson")
token = request("token")
Set json = getjson(userJson)

if iType = "one" then
	for i=0 to json.length-1
		set rs= server.createobject("adodb.recordset")
		sqlstr = "select count(*) as cc from userInfo where userId='"&json.get(i).userId&"'"
		rs.open sqlstr,conn,1,1
		if rs("cc") = 0 then
			sql="insert into userInfo ([userId],[username],[password],[token],[p],[v1]) values ('"&json.get(i).userId&"','"&json.get(i).email&"','','"&token&"','','')"
			conn.execute(sql)
		else
			sql="update [userInfo] set [userId]='"&json.get(i).userId&"',[username]='"&json.get(i).email&"',[token]='"&token&"',[v1]='0' where userId='"&json.get(i).userId&"'"
			conn.execute(sql)
		end if
	Next
end if

if iType = "more" then
	for i=0 to json.length-1
		set rs= server.createobject("adodb.recordset")
		sqlstr = "select count(*) as cc from userInfo where username='"&json.get(i).displayName&"'"
		rs.open sqlstr,conn,1,1
		if rs("cc") = 0 then
			sql="insert into userInfo ([userId],[username],[password],[p],[v1]) values ('"&json.get(i).userId&"','"&json.get(i).displayName&"','','','')"
			conn.execute(sql)
		else
		end if
		'response.write json.get(i).basicInfo.realname
	Next
end if



'Dim objTest
'InitScriptControl
'Set objTest = getJSONObject(strTest)

	



conn.close

%>
